<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // sessionStorage localStorage
        // 存储 注意！数组和对象的存储与取出必须要序列化和反序列化
        // sessionStorage.setItem('n1', '123');
        // const obj = {
        //     id: 12,
        //     name: 'wang',
        //     t: ['123', '455']
        // }
        // sessionStorage.setItem('n2', JSON.stringify(obj))


        // 取出
        let n1 = sessionStorage.getItem('n1');
        let n2 = JSON.parse(sessionStorage.getItem('n2'));
        console.log(n1);
        console.log(n2);
        
        // 删除
        sessionStorage.removeItem('n1');
        sessionStorage.removeItem('n2');
    </script>
</body>
</html>